package com.example.rabbitmq.sender;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Copyright(C), 2020-2021, AmbroseCdMeng
 * FileName:    SenderA
 * Author:      AmbroseCdMeng
 * Date:        2021/2/27 15:14
 * Description: 发送者 A
 * History:
 * <author>     <time>      <version>       <desc>
 * 作者姓名     修改时间        版本号           描述
 */
@Component
public class SenderA {
    @Autowired
    private AmqpTemplate rabbitTemplate;
    public void send(String context){
        System.out.println("Sender: " + context);
        // 使用 AmqpTemplate 将消息发送到消息队列中
        this.rabbitTemplate.convertAndSend("Queue1", context);
    }
}
